package com.hunan.yllxy.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Author: 刘华
 * @Date: 2024/10/23 上午10:01
 * @Version 1.0
 */
@Data
public class StatisticsVo {

    private Object params;
    private String name;
    private Integer valueInt;
    private Long valueLong;
    private Double valueDouble;
    private PercentVo percentVo;

    public StatisticsVo(String name, Long valueLong) {
        this.name = name;
        this.valueLong = valueLong;
    }

    public StatisticsVo(String name, Double valueDouble) {
        this.name = name;
        if (valueDouble!=null){
            // 将Double转换为BigDecimal（推荐通过字符串避免精度丢失）
            BigDecimal bd = new BigDecimal(valueDouble.toString());
            // 保留两位小数，四舍五入
            bd = bd.setScale(2, RoundingMode.HALF_UP);

            // 转换回Double（注意：可能仍存在double的精度限制）
            this.valueDouble = bd.doubleValue();

        }

    }

    public StatisticsVo(String name, Integer valueInt) {
        this.name = name;
        this.valueInt = valueInt;
    }

    public StatisticsVo(String name, Integer valueInt, PercentVo percentVo) {
        this.name = name;
        this.valueInt = valueInt;
        this.percentVo = percentVo;
    }

    public StatisticsVo(String name, Long valueLong, PercentVo percentVo) {
        this.name = name;
        this.valueLong = valueLong;
        this.percentVo = percentVo;
    }

    public StatisticsVo(String name, PercentVo percentVo) {
        this.name = name;
        this.percentVo = percentVo;
    }

    public StatisticsVo(String name, Double valueDouble, PercentVo percentVo) {
        this.name = name;
        this.valueDouble = valueDouble;
        this.percentVo = percentVo;
    }

    public StatisticsVo(Object params, String name, Integer valueInt, Long valueLong, Double valueDouble, PercentVo percentVo) {
        this.params = params;
        this.name = name;
        this.valueInt = valueInt;
        this.valueLong = valueLong;
        this.valueDouble = valueDouble;
        this.percentVo = percentVo;
    }

    public StatisticsVo() {
    }
}
